package model

import (
	"time"
)

type Article struct {
	ID         uint64    `gorm:"primaryKey;autoIncrement;comment:'文章id'" json:"id"`
	Title      string    `gorm:"type:varchar(120);not null;default:'';comment:'文章标题'" json:"title"`
	Cover      string    `gorm:"type:varchar(120);not null;default:'';comment:'文章封面'" json:"cover"`
	Summary    *string   `gorm:"type:varchar(160);comment:'文章摘要'" json:"summary"`
	CreateTime time.Time `gorm:"type:datetime;not null;default:CURRENT_TIMESTAMP;comment:'创建时间';index:idx_create_time" json:"create_time"`
	UpdateTime time.Time `gorm:"type:datetime;not null;default:CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP;comment:'最后一次更新时间'" json:"update_time"`
	IsDeleted  int8      `gorm:"type:tinyint(2);not null;default:0;comment:'删除标志位：0：未删除 1：已删除'" json:"is_deleted"`
	ReadNum    int       `gorm:"type:int unsigned;not null;default:1;comment:'被阅读次数'" json:"read_num"`
	Weight     *int      `gorm:"type:int;comment:'权值，越大排名越靠前'" json:"weight"`
}

func (Article) TableName() string {
	return "t_article"
}
